package per.ace.actuator.endpoints;

import org.springframework.boot.actuate.endpoint.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @program: springbootDemo
 * @description: 自定义actuator端点 url:http://localhost:8081/actuator/myEndpoint
 * @author: ace
 * @Date: 2020-01-01 18:17
 **/
@Endpoint(id = "myEndpoint")
@Component
public class MyEndpoint {

    String name = "default";

    @ReadOperation
    public String getName() {
        return "{\"name\":\"" + name + "\"}";
    }

    @WriteOperation
    public void setName(@Selector String name) {
        this.name = name;
    }

    @DeleteOperation
    public void delName() {
        name = "";
    }
}
